package main

import "fmt"

type R_error struct {
	msg  string
	code string
	inf  int
}

func (e *R_error) ok() bool {
	if e != nil {
		return false
	} else {
		return true
	}
}
func (e *R_error) error() bool {
	if e != nil {
		return true
	} else {
		return false
	}
}
func (e *R_error) info() string {
	return e.code
}

func (e *R_error) Error() string {
	return fmt.Sprintln("msg:", e.msg, " code:", e.code, " info:", e.info)
}

func test1(i int) (int, error) {
	if i < 0 {
		return -1, &R_error{msg: "i<0", code: "error", inf: i}
	} else if i == 0 {
		return 0, &R_error{msg: "i==0", code: "warring", inf: i}
	} else {
		return 1, nil
	}
}

func main() {
	i, err := test1(-1)
	if err != nil {
		RErr := err.(*R_error)
		fmt.Println(RErr.ok(), " ", RErr.info())
		if RErr.info() == "error" {
			fmt.Println("error ", 100)
		} else if RErr.info() == "warring" {
			fmt.Println("warring ", 1)
		}
	} else {
		fmt.Println(i)
	}
	i, err = test1(0)
	if err != nil {
		RErr := err.(*R_error)
		fmt.Println(RErr.ok(), " ", RErr.info())
		if RErr.info() == "error" {
			fmt.Println("error ", 100)
		} else if RErr.info() == "warring" {
			fmt.Println("warring ", 1)
		}
	} else {
		fmt.Println(i)
	}
	i, err = test1(1)
	if err != nil {
		RErr := err.(*R_error)
		fmt.Println(RErr.ok(), " ", RErr.info())
		if RErr.info() == "error" {
			fmt.Println("error ", 100)
		} else if RErr.info() == "warring" {
			fmt.Println("warring ", 1)
		}
	} else {
		fmt.Println(i)
	}
}
